package org.jiulou.web.validator;

import org.jiulou.vo.LoginVo;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

@Component("loginValidator")
public class LoginValidator implements Validator{

	@Override
	public boolean supports(Class<?> clazz) {
		return LoginVo.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username"
				,"validator.field.required","必须输入用户名");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password"
				,"validator.field.required","必须输入密码");	
	}
}
